<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LuckSheet Export</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- luckysheet -->
<link rel='stylesheet' th:href='@{luckysheet/dist/plugins/css/pluginsCss.css}' />
<link rel='stylesheet' th:href='@{luckysheet/dist/plugins/plugins.css}' />
<link rel='stylesheet' th:href='@{luckysheet/dist/css/luckysheet.css}' />
<link rel='stylesheet' th:href='@{luckysheet/dist/assets/iconfont/iconfont.css}' />
<script th:src="@{luckysheet/dist/plugins/js/plugin.js}"></script>
<script th:src="@{luckysheet/dist/luckysheet.umd.js}"></script>
<!-- zTree -->
<link rel="stylesheet" th:href="@{css/demo.css}" type="text/css">
<link rel="stylesheet" th:href="@{css/metroStyle.css}" type="text/css">
<script type="text/javascript" th:src="@{js/jquery.ztree.core.min.js}"></script>
<script type="text/javascript" th:src="@{js/jquery.ztree.excheck.min.js}"></script>
<script type="text/javascript" th:src="@{js/jquery.ztree.exedit.min.js}"></script>
</head>
<body>
	
	<div id="luckysheet"
		style="margin: 0px; padding: 0px; position: absolute; width: 100%; height: 100%; left: 0px; top: 0px;"></div>

</body>

<script>
	//loadUrl是返回luckysheet 数据的后台api接口
	var options = {
		container : 'luckysheet', //luckysheet为容器id
		//title : '导出表格', // 设定表格名称
		//showinfobar:false,
		lang : 'zh', // 设定表格语言
		allowEdit : true,//作用：是否允许前台编辑
		showinfobar : true,//作用：是否显示顶部信息栏
		myFolderUrl : "",//作用：左上角<返回按钮的链接
		functionButton : '<button id="" class="btn btn-primary btn-danger" style=" padding:3px 6px; font-size: 12px; margin-right: 85px;" onclick="exportHandle()">导出</button>',
		loadUrl : "",
	}
	$(function() {
		//配置项
		luckysheet.create(options)
	})

	//导出函数
	function exportHandle() {
		var jsdata = new Array();
		var sheets = luckysheet.getAllSheets();
		for (var i = 0; i < sheets.length; i++) {
			jsdata.push({
				"name" : sheets[i].name,
				"celldata" : sheets[i].celldata,
				"config" : sheets[i].config,
				"images" : sheets[i].images,
				"frozen" : sheets[i].frozen,
				"dataVerification" : sheets[i].dataVerification,

			});
		}
		console.log("JSON.stringify(jsdata) = " + JSON.stringify(jsdata))
		var form = document.createElement("form");
		form.method = 'post';
		form.action = '/excel/exportFile';
		form.style = 'display:none';
		form.enctype = 'multipart/form-data';
		document.body.appendChild(form);
		var newElement = document.createElement("textarea");
		newElement.setAttribute("type", "hidden");
		newElement.name = "exceldata";
		newElement.value = JSON.stringify(luckysheet.getAllSheets());
		form.appendChild(newElement);
		form.submit();
	}
</script>
</html>
